from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base

engine = create_engine("postgresql://postgres:123456@localhost:5432/drugstore", echo=True, pool_recycle=3600)
Session = sessionmaker(bind=engine)
db_session = scoped_session(Session)  # 用于操作数据库表, scoped_session 保证线程安全
Base = declarative_base()  # 创建表的语句
